package Array_Object;

import java.util.Scanner;

/**
 * ClassName:CarTest
 * Package:Array_Object
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/15-12:20
 * @Version:v1.0
 */
public class CarTest {
    public static void main(String[] args) {
        //创建数组，存放汽车对象
        Car[] arr = new Car[3];

        //创建汽车对象
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            Car c = new Car();
            //录入品牌
            System.out.println("请输入汽车的品牌:");
            String brand = sc.next();
            c.setBrand(brand);
            //录入价格
            System.out.println("请输入汽车的价格:");
            int prices = sc.nextInt();
            c.setPrices(prices);
            //录入颜色
            System.out.println("请输入汽车的颜色");
            String color = sc.next();
            c.setColor(color);
            arr[i] = c;

        }
        for (int i = 0; i < arr.length; i++) {
            Car car = arr[i];
            System.out.println(car.getBrand() + "," + car.getPrices() + "," + car.getColor());
        }
    }
}
